﻿package misc {	import misc.*;	import flash.display.*;	import flash.events.*;	import flash.utils.*;	import flash.geom.*;	import flash.ui.*;		public class Parallax extends Entity {				[Inspectable(defaultValue=0.5)]		public var factorX:Number = 0.5;				[Inspectable(defaultValue=0.5)]		public var factorY:Number = 0.5;				public var parentInitPos:Point;				public var initPos:Point;		public var offset:Point;				public override function create():void {			offset = new Point(x, y);			initPos = parent.localToGlobal(new Point(0, 0));			parentInitPos = new Point(parent.x, parent.y);			listenWhileVisible(stage, Event.ENTER_FRAME, update, false, -99999);		}				public function update(e:Event):void {			var newPos:Point = parent.globalToLocal(initPos);			x = newPos.x * factorX + offset.x;			y = newPos.y * factorY + offset.y;		}	}}